{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b8cab319",
   "metadata": {},
   "source": [
    "* 2022/09/13week04    \n",
    "* python课堂笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf46c27d",
   "metadata": {},
   "source": [
    "# 回顾总结"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e0ee773",
   "metadata": {},
   "source": [
    "## 1.变量       \n",
    "* 定义：变量是编程语言中能存储数据的抽象概念，它可以存储各种数据。      \n",
    "* 隐喻：变量就像是水杯，能存放各种不同的饮料      \n",
    "     \n",
    "**注意变量名只能由字母、数字、下划线组成。**    \n",
    "**1. 不能以数字开头；**      \n",
    "**2. 不能包含空格；**     \n",
    "**3. 大小写敏感，变量A和变量a是不同的**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de8c8a8e",
   "metadata": {},
   "source": [
    "## 2.常量    \n",
    "* 定义：常量是指在程序运行时不能被修改的数据。\n",
    "* 比如整数175，小数52.5，字符串“Jungkook”都是常量，它们是不能被修改的。\n",
    "* 隐喻：常量就像是饮料本身，咖啡就是咖啡，茶就是茶，它可以被装到不同容器里面，但是它们本身的性质是不会改变的。      \n",
    "       \n",
    "**存储到变量里面的具体数据又叫常量。**      \n",
    "**例如一个整数，2018；一个小数，3.1415926；一段文字，I love you 等等。**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e42ef90",
   "metadata": {},
   "source": [
    "## 3.赋值\n",
    "* 如同把饮料倒入水杯一样，在 Python 中, 把一个常量放入变量的过程就叫做赋值。      \n",
    "* 赋值需要用到等号“=”，所以等号“=”又叫做“赋值运算符”。      \n",
    "\n",
    "**赋值是一个过程**    \n",
    "**赋值的对象是变量**    \n",
    "**赋值需要把一个数值放入一个变量**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a5bc5f89",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 赋值符号“=”代表把一个数据装入变量的过程。\n",
    "# 比如，我们把 \"Tony\" 装入 name ，这个过程就叫赋值。      \n",
    "name = \"python\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2f2513cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jungkook\n"
     ]
    }
   ],
   "source": [
    "# 第一行把名字\"Jungkook\"赋值给变量 name；\n",
    "# 第二行使用 print() 输出变量 name 的值。     \n",
    "name = \"Jungkook\"     \n",
    "print(name)\n",
    "\n",
    "#⚠️注意，输出变量时是不需要添加引号的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "193fb05d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "901\n"
     ]
    }
   ],
   "source": [
    "# 除了用常量给变量进行赋值，还可以用一个变量给另一个变量赋值\n",
    "ABC = 901\n",
    "abc = ABC\n",
    "print(abc)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f048e5d3",
   "metadata": {},
   "source": [
    "#### 小试一下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ba433837",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jungkook\n"
     ]
    }
   ],
   "source": [
    "#第一行把名字 \"Jungkook\" 赋值给变量 name；       \n",
    "#第二行把变量 name 赋值给变量 myName；         \n",
    "#第三行使用 print() 输出变量 myName 的值。   \n",
    "\n",
    "name = \"Jungkook\"\n",
    "myName = name\n",
    "print(myName)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1225c65b",
   "metadata": {},
   "source": [
    "## 4.转义字符      \n",
    "* 定义：转义字符是一种特殊的字符，它们以反斜线 \\ 开头，例如换行符 \\n 。      \n",
    "* 当字母 n 与反斜线 \\ 结合后，它们的含义和功能相比之前发生了转变，因此这样的字符被称为转义字符。      \n",
    "* 隐喻：转义字符就像标记笔，标记之后的内容不能被正常解释为字符，需要做特殊解释"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8c83e752",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天是个好天气，\n",
      "我在学习python课，\n",
      "老师是超哥，\n",
      "学习快乐快乐学习。\n"
     ]
    }
   ],
   "source": [
    "print(\"今天是个好天气，\\n我在学习python课，\\n老师是超哥，\\n学习快乐快乐学习。\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "47f03aaa",
   "metadata": {},
   "source": [
    "## 格式化输出     \n",
    "\n",
    "* 作用：格式化输出让我们可以对字符串里的内容进行灵活替换。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0e6237f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "My name is VV\n",
      "My name is Jungkook\n"
     ]
    }
   ],
   "source": [
    "# 第1、4行代码分别对变量 name 进行了赋值；      \n",
    "# 第2、5行代码则是在两个字符串中分别填入了变量 name 的值，并输出这两个字符串。\n",
    "\n",
    "name = \"VV\"\n",
    "print(f\"My name is {name}\")\n",
    "\n",
    "name = \"Jungkook\"\n",
    "print(f\"My name is {name}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "719c1dcc",
   "metadata": {},
   "source": [
    "## f     \n",
    "\n",
    "* 字符串之前的小写字母 f 表示这个字符串需要进行格式化输出。\n",
    "\n",
    "**注意，不可以使用大写字母 F 。**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea7c32df",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "ce6ae7f6",
   "metadata": {},
   "source": [
    "# 回顾上周内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "130083db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 上周回顾（range（））       \n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "94587666",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)\n",
    "# 执行了五次， for＋range 决定循环的次数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "fbaab761",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 5)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3da38f13",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8834be5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "06465a2c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "4\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,10,3):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "e0e981b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# start? stop? step?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d3ac9a1",
   "metadata": {},
   "source": [
    "# 本周内容      \n",
    "\n",
    "* type():检查类型\n",
    "\n",
    "\n",
    "> 1.数值\n",
    ">> 1. int\n",
    ">> 2. float\n",
    ">> 3. complex     \n",
    "\n",
    "\n",
    "> 2.字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a34a2d54",
   "metadata": {},
   "source": [
    "# 1. 数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "401185dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9 <class 'int'>\n"
     ]
    }
   ],
   "source": [
    "## Number(数值)\n",
    "## int\n",
    "a = 9\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "3a438e46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11.5 <class 'float'>\n"
     ]
    }
   ],
   "source": [
    "## float\n",
    "b = 11.5\n",
    "print(b,type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "11cc40ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5+3j) <class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "## complex(虚数，复数)\n",
    "c = 5 + 3j\n",
    "print(c,type(c))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58708b2f",
   "metadata": {},
   "source": [
    "# 2.字符串（string）\n",
    "\n",
    "> 1. 关于字符串的基本内容\n",
    "> 2. 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e473ebea",
   "metadata": {},
   "source": [
    "### 2.1关于字符串的基本内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "594b66b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alex <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "name = \"Alex\"\n",
    "print(name,type(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "17b599ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'\n",
    "# 斜杠是转义符号，吹现在代码中不会出现，但其后面的符号会出现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "aec51a71",
   "metadata": {},
   "outputs": [],
   "source": [
    "nfu_index_pages_html =\"\"\"\n",
    "\n",
    "<head>\n",
    "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
    "    <title>南方学院文学与传媒学院</title>\n",
    "    <meta name=\"description\" content=\"\" />\n",
    "    <meta name=\"keywords\" content=\"\" />\n",
    "    <meta name=\"description\" content=\"\">\n",
    "    <meta name=\"wap-font-scale\" content=\"no\">\n",
    "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0,user-scalable=no\">\n",
    "    <meta content=\"IE=edge,chrome=1\" http-equiv=\"X-UA-Compatible\">\n",
    "    <link rel=\"stylesheet\" href=\"css/cui.css\">\n",
    "    <link rel=\"stylesheet\" href=\"css/lib.css\">\n",
    "    <link rel=\"stylesheet\" href=\"css/style.css\">\n",
    "    <link rel=\"stylesheet\" href=\"css/less.css\">\n",
    "    <script src=\"js/jquery.js\"></script>\n",
    "</head>\n",
    "<body class=\"index\" style=\"cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\">\n",
    "<link href=\"css/jiathis_share.css\" rel=\"stylesheet\" type=\"text/css\">\n",
    "<div class=\"jiathis_style\" style=\"position: absolute; z-index: 1000000000; display: none; top: 50%; left: 50%; overflow: auto;\"></div>\n",
    "<div class=\"jiathis_style\" style=\"position: absolute; z-index: 1000000000; display: none; overflow: auto;\"></div>\n",
    "\n",
    "<div id=\"index\" class=\"index-bg\">\n",
    "    <div class=\"bg\"></div>\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "4b331346",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "<head>\n",
      "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
      "    <title>南方学院文学与传媒学院</title>\n",
      "    <meta name=\"description\" content=\"\" />\n",
      "    <meta name=\"keywords\" content=\"\" />\n",
      "    <meta name=\"description\" content=\"\">\n",
      "    <meta name=\"wap-font-scale\" content=\"no\">\n",
      "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0,user-scalable=no\">\n",
      "    <meta content=\"IE=edge,chrome=1\" http-equiv=\"X-UA-Compatible\">\n",
      "    <link rel=\"stylesheet\" href=\"css/cui.css\">\n",
      "    <link rel=\"stylesheet\" href=\"css/lib.css\">\n",
      "    <link rel=\"stylesheet\" href=\"css/style.css\">\n",
      "    <link rel=\"stylesheet\" href=\"css/less.css\">\n",
      "    <script src=\"js/jquery.js\"></script>\n",
      "</head>\n",
      "<body class=\"index\" style=\"cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\">\n",
      "<link href=\"css/jiathis_share.css\" rel=\"stylesheet\" type=\"text/css\">\n",
      "<div class=\"jiathis_style\" style=\"position: absolute; z-index: 1000000000; display: none; top: 50%; left: 50%; overflow: auto;\"></div>\n",
      "<div class=\"jiathis_style\" style=\"position: absolute; z-index: 1000000000; display: none; overflow: auto;\"></div>\n",
      "\n",
      "<div id=\"index\" class=\"index-bg\">\n",
      "    <div class=\"bg\"></div>\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(nfu_index_pages_html)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68c3db63",
   "metadata": {},
   "source": [
    "### 2.2 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "8e396146",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广南学院坐落于广州市从化温泉镇\n"
     ]
    }
   ],
   "source": [
    "# 关于有序性\n",
    "title = \"广南学院坐落于广州市从化温泉镇\"\n",
    "print(title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "4fa5ca3a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[0] # 取单一值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "87adf2b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[1] # 取单一值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "a21a3559",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'镇'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[-1] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "2158c5cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'泉'"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[-2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "a7a9d880",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广南学院'"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[0:4] # 取一定范围的值，这种方法我们称其为“切片”，第一个值为0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "15fb134d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(title) # 检查文本的总长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "3f8c2d90",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广南学院'"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title[:4] # 0可以省略不写"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12adc0a4",
   "metadata": {},
   "source": [
    "##  enumerate举例/举例，既可以获取到内容/item，又可以获取到 索引值/index。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "5c67f606",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 广\n",
      "1 南\n",
      "2 学\n",
      "3 院\n",
      "4 坐\n",
      "5 落\n",
      "6 于\n",
      "7 广\n",
      "8 州\n",
      "9 市\n",
      "10 从\n",
      "11 化\n",
      "12 温\n",
      "13 泉\n",
      "14 镇\n"
     ]
    }
   ],
   "source": [
    "## 利用for循环 遍历文本信息\n",
    "for i,j in enumerate (title):\n",
    "    print(i,j)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a31693bf",
   "metadata": {},
   "source": [
    "## 思考： 如何判断一段文本中是否存在“广州”，例如文本 title 中的内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4c81946",
   "metadata": {},
   "source": [
    "### 方法1："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "165d87d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州这个词在文本中\n"
     ]
    }
   ],
   "source": [
    "for i,j in enumerate (title):\n",
    "    if j == \"广\":\n",
    "        if title[i+1] == \"州\":\n",
    "            print(\"广州这个词在文本中\")\n",
    "# 这个方法还能检查“广州”出现了几次 如果title里有两个“广州”,那么“广州这个词在文本中” 将会出现两次"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79b352a0",
   "metadata": {},
   "source": [
    "###  例子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "7f900ac4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院坐落在广州从化温泉镇\n"
     ]
    }
   ],
   "source": [
    "title = \"广州南方学院坐落在广州从化温泉镇\"\n",
    "print(title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "96b8bb3b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州这个词在文本中\n",
      "广州这个词在文本中\n"
     ]
    }
   ],
   "source": [
    "for i,j in enumerate (title):\n",
    "    if j == \"广\":\n",
    "        if title[i+1] == \"州\":\n",
    "            print(\"广州这个词在文本中\")\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4d3eb680",
   "metadata": {},
   "source": [
    "### 方法2："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "38160bbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## P59   in 检查成员对象\n",
    "\"广州\" in title"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21ca26b3",
   "metadata": {},
   "source": [
    "# 字符串的拼接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "4fecf016",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你好,VV\n"
     ]
    }
   ],
   "source": [
    "print(\"你好\" + \",\" +\"VV\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "4f2fb06f",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can only concatenate str (not \"int\") to str",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [78]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# 字符串不可以和数字进行连接\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m你好\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mVV\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[1;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
     ]
    }
   ],
   "source": [
    "# 字符串不可以和数字进行连接\n",
    "print(\"你好\" + 1 + \"VV\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "47d9c529",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for /: 'str' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [81]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# 字符串不能用来运算\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m3\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'str' and 'str'"
     ]
    }
   ],
   "source": [
    "# 字符串不能用来运算\n",
    "\"3\"/\"2\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "b60dba3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "width = 3\n",
    "heigt = 9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "eca36a95",
   "metadata": {},
   "outputs": [],
   "source": [
    "面积 = width * heigt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "8eceb67e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "面积"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "26fa80df",
   "metadata": {},
   "source": [
    "* 字符串的方法\n",
    "\n",
    "> 1. str.capitalize():可以将首字母转成大写\n",
    "> 2. str.cont():数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "7c564679",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = \"jungkook\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "0cdd7c3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Jungkook'"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name.capitalize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "1cee035d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name.count(\"j\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "228c62e5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院坐落在广州从化温泉镇'"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "f88ab21d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title.count(\"新媒体\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "f71bb785",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['广州南方学院坐落在广州从化温泉镇']"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title.split(\"坐落于\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
